package com.iot08.api.service;

import com.iot08.common.entity.app.Payment;
import com.iot08.common.service.base.BaseService;
import com.iot08.common.utils.DateUtil;
import com.iot08.common.utils.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @version 1.0
 * @Description:
 * @author: Rock
 * @time: 2021/2/27 9:59
 */
@Service
public class PaymentService extends BaseService<Payment> {

    /**
     * @param imei
     * @param openid
     * @param type
     * @param orderid
     * @param outTradeNo
     * @time: 2021/2/27 12:06
     * @author: Rock
     * @version 1.0
     */
    public Payment add(String imei, String openid, String type, String orderid,String outTradeNo) {
        Payment payment = new Payment();
        if(StringUtils.isNotEmpty(imei)){
            payment.setImei(imei);
        }
        payment.setOpenid(openid);
        payment.setType(type);
        payment.setOrderid(orderid);
        payment.setOutTradeNo(outTradeNo);
        payment.setStatus(0);
        payment.setCreateTime(DateUtil.getDate(new Date()));
        this.save(payment);
        return payment;
    }

}
